<template>
	<el-card class="layout-query">
		<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
			<el-form-item prop="showNickName">
				<el-input v-model="state.queryForm.showNickName" placeholder="群内昵称"></el-input>
			</el-form-item>
			<el-form-item prop="createdTime">
				<el-date-picker v-model="state.queryForm.createdTime" type="daterange" range-separator="-"
					start-placeholder="进群时间从" end-placeholder="至" value-format="YYYY-MM-DD HH:mm:ss" />
			</el-form-item>
			<el-form-item>
				<el-button icon="Search" type="primary" @click="getDataList()">查询</el-button>
			</el-form-item>
			<el-form-item>
				<el-button icon="RefreshRight" @click="reset(queryRef)">重置</el-button>
			</el-form-item>
		</el-form>
	</el-card>
	<el-card>
		<el-table v-loading="state.dataListLoading" :data="state.dataList" border class="layout-table">
			<el-table-column prop="headImage" label="用户头像" header-align="center" align="center">
				<template #default="scope">
					<el-avatar shape="square" :size="35" :src="scope.row.headImage"></el-avatar>
				</template>
			</el-table-column>
			<el-table-column prop="userName" label="用户名" header-align="center" align="center"></el-table-column>
			<el-table-column prop="showNickName" label="群内昵称" header-align="center" align="center"></el-table-column>
			<el-table-column prop="createdTime" label="进群时间" header-align="center" align="center"></el-table-column>
		</el-table>
		<el-pagination :current-page="state.page" :page-sizes="state.pageSizes" :page-size="state.limit"
			:total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="sizeChangeHandle"
			@current-change="currentChangeHandle">
		</el-pagination>

	</el-card>
</template>

<script setup lang="ts" name="ImGroupMemberIndex">
import { useCrud } from '@/hooks'
import { reactive, ref } from 'vue'
import { IHooksOptions } from '@/hooks/interface'


const state: IHooksOptions = reactive({
	createdIsNeed: false,
	dataListUrl: '/im/group/member/page',
	queryForm: {
	}
})

const queryRef = ref()

const init = (id: number) => {
	console.log("init")
	state.queryForm.groupId = id
	console.log(state.queryForm)
	getDataList()
}

defineExpose({
	init
})

const { getDataList, sizeChangeHandle, currentChangeHandle, reset } = useCrud(state)
</script>
